<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<link rel="stylesheet" href="./styles/css/common.css">
	<link rel="stylesheet" href="./styles/css/mui.min.css">
	<link rel="stylesheet" href="./styles/css/mui.picker.min.css">
	<link rel="stylesheet" href="./styles/css/index.css">
	<title>离校未就业毕业生实名制登记</title>
</head>

<body style="position: relative;">
	<div class="header">
		<i class="goback J_goback"></i> 离校未就业毕业生实名制登记
	</div>

	<div class="content" id="J_area">
		<div class="scroll_con">
			<div id="dataForm">
				<form name='form_dw' msgtype="1" validate="blur">
					<div class="order_content">
						<div class="row">
							<div class="col-3"><span style="color:#fd4242">*</span>是否北京生源：</div>
							<div class="col-8">
								<select class="kwjg" id="isBjsy" valiflag=",full,是否北京生源" paramete="sfbjsy" v_require>
									<option value="1">是</option>
									<option value="0">否</option>
								</select>
							</div>
						</div>
						<div class="row">
							<div class="col-3"><span style="color:#fd4242">*</span> 生源地：</div>
							<div class="col-8">
								<select class="kwjg" id="syd" valiflag=",full,生源地" paramete="rxqhkszdxzqh" v_require>
								</select>
							</div>
						</div>
						<div class="row">
							<div class="col-3"><span style="color:#fd4242">*</span> 学历：</div>
							<div class="col-8">
								<select class="kwjg" id="xl" valiflag=",full,学历" paramete="xl" v_require>
								</select>
							</div>
						</div>
						<div class="row">
							<div class="col-3"><span style="color:#fd4242">*</span> 毕业学校：</div>
							<div class="col-8">
								<input type="text" class="kwjg" id="byxx" placeholder="请填写毕业学校" valiflag="225,full,毕业学校" paramete="byxx" v_require>
							</div>
						</div>
						<div class="row">
							<div class="col-3"><span style="color:#fd4242">*</span> 毕业时间：</div>
							<div class="col-8">
								<input type="text" class="kwjg J_date" placeholder="请填写毕业时间" readonly id="byrq" valiflag=",,毕业时间" paramete="byrq" v_require>
							</div>
						</div>
						<div class="row">
							<div class="col-3"><span style="color:#fd4242">*</span> 毕业年度：</div>
							<div class="col-8">
								<select class="kwjg" id="bynd" valiflag=",full,毕业年度" paramete="bynd" v_require>
								</select>
							</div>
						</div>
						<div class="row">
							<div class="col-3"><span style="color:#fd4242">*</span> 所学专业：</div>
							<div class="col-8">
								<input type="text" class="kwjg J_sxzy" readonly placeholder="请填写所学专业" id="sxzy" xzqhid="" valiflag=",,所学专业" paramete="sxzy"
								 v_require>
							</div>
						</div>
						<div class="row">
							<div class="col-3"><span style="color:#fd4242">*</span> 手机号码：</div>
							<div class="col-8">
								<input type="text" class="kwjg" id="sjhm" placeholder="请填写手机号码" valiflag="11,phone,手机号码" paramete="sjhm" v_require>
							</div>
						</div>
						<div class="row J_hkszd" style="display: none">
							<div class="col-3 "><span style="color:#fd4242">*</span> 户口所在地：</div>
							<div class="col-8">
								<select class="kwjg" id="hjszd" valiflag=",full,户口所在地" paramete="hjqWs">
								</select>
							</div>
						</div>
						<div class="row J_szq">
							<div class="col-3"><span style="color:#fd4242">*</span> 户口所在区：</div>
							<div class="col-8">
								<select class="kwjg" id="hjq" valiflag=",full,户口所在区" paramete="hjq" v_require>
								</select>
							</div>
						</div>
						<div class="row J_szq_detail">
							<div class="col-3"><span style="color:#fd4242">*</span>户口详细地址：</div>
							<div class="col-8">
								<input type="text" class="kwjg" id="hjszxxdz" placeholder="请填写户口所在地详细地址" valiflag="384,full,户口所在地详细地址" paramete="hjszxxdz"
								 v_require>
							</div>
						</div>
						<div class="row">
							<div class="col-3">就业意向：</div>
							<div class="col-8">
								<input type="text" class="kwjg" id="jyyx" placeholder="请填写就业意向" valiflag="90,full,就业意向" paramete="jyyx">
							</div>
						</div>
						<div class="row">
							<div class="col-3">月薪要求：</div>
							<div class="col-8">
								<input type="text" class="kwjg" id="yxyq" placeholder="请填写月薪要求" valiflag="128,full,月薪要求" paramete="yxyq">
							</div>
						</div>
						<input type="text" style="display: none" class="ryid" id="ryid" paramete="ryid" v_require>
					</div>
				</form>
			</div>

			<div class="order_btn">
				<button type="button" class="mui-btn mui-btn-primary J_save" style="margin-right: 0.3rem;">保存</button>
				<button type="button" class="mui-btn J_reset">重置</button>
			</div>
		</div>
	</div>

</body>
<script src="./common/mui/mui.min.js"></script>
<script src="./common/mui/mui.picker.js"></script>
<script src="./common/mui/mui.poppicker.js"></script>
<script src="./common/mui/mui.dtpicker.js"></script>
<script src="./common/rem.js"></script>
<script src="./common/vendor.js"></script>
<script src="./common/common.js"></script>
<script src="./common/validator.js"></script>
<script src="./common/levelPlugin.js"></script>
<script>
	$(function () {
		var load = new $.Loading();
		var allObj = {}; //全局对象
		var studyArr = []; //所学专业数组
		var dtPicker;

		$(document).on('click', '.J_goback', function () {
			// window.history.go(-1);
			// window.location.href = document.referrer;
			window.location.href = './index.html';
		})

		var popPicker = new mui.PopPicker({
			layer: 2
		});
		// 获取代码表
		dmb();

		// 毕业时间事件
		$(document).on('click', '.J_date', function () {
			var _val = $(this).val();
			var _this = $(this);
			if (_val) {
				dtPicker.setSelectedValue(_val)
			}
			dtPicker.show(function (selectItems) {
				_this.val(selectItems.text)
			})
		})
		// 所学专业事件
		$(document).on('click', '.J_sxzy', function () {
			var xzqhid = $(this).attr('xzqhid');
			var _val = $(this).val();
			var _this = $(this);
			if (xzqhid) {
				// 设置区划默认值
				if (xzqhid.indexOf('0000') != -1) {
					popPicker.pickers[0].setSelectedValue(xzqhid);
				} else {
					var FirstVal = xzqhid.substring(0, 2) + '0000';
					popPicker.pickers[0].setSelectedValue(FirstVal, 0, function () {
						popPicker.pickers[1].setSelectedValue(xzqhid);
					});
				}
			}

			popPicker.show(function (selectItems) {
				var _value = '';
				var _text = '';
				if (selectItems[1].value != undefined) {
					_value = selectItems[1].value;
					_text = selectItems[0].text + selectItems[1].text;
				} else {
					_value = selectItems[0].value;
					_text = selectItems[0].text;
				}
				_this.val(_text);
				_this.attr('xzqhid', _value);
			})

		})
		// 点击保存
		$(document).on('click', '.J_save', function () {
			if (!validate('form_dw')) return false;
			$.layerMsg("确定要保存吗？", [{
				text: '确定', cb: function () {
					var _data = $('#dataForm').getFormData();
					_data.sxzy = $('#sxzy').attr('xzqhid');
					load.on();
					$.fetch({
						url: '/smzdj/smzdjBc',
						type: 'post',
						data: _data
					}).always(function () {
						load.off();
					}).done(function (res) {
						if (res.returnData.executeResult == 1) {
							$.layerMsg(res.returnMsg, '我知道了', function () {
								search();
							});
						}
					})
				}
			}, {
				text: '取消', cb: function () {

				}
			}])
		})

		// 重置
		$(document).on('click', '.J_reset', function () {
			if (allObj.flag == 0) return false;
			search();

		})
		// 查询
		function search() {
			load.on();
			$.fetch({
				url: '/smzdj/smzdjCx',
				type: 'get'
			}).always(function () {
				load.off();
			}).done(function (res) {
				var _res = res.returnData;
				if (+_res.executeResult == 1) {
					allObj = _res.smzdj;
					var isBjsy = allObj.sfbjsy == 0 ? 0 : 1;
					if (isBjsy == 1) { //是北京生源
						$('#isBjsy').val(isBjsy);//是北京生源
						$.renderCode($('#syd'), 'gxbysjycy_d_xzqh', '', '', function () {
							$('#syd').val(allObj.rxqhkszdxzqh);
						});//生源地
						$('#hjq').attr('paramete', 'hjq');
						$('#hjszxxdz').attr('paramete', 'hjszxxdz');
						$('.J_szq .col-3').html('<span style="color:#fd4242">*</span>户口所在区：');
						$('.J_szq #hjq').attr('valiflag', ',full,户口所在区');
						$('.J_szq_detail .col-3').html('<span style="color:#fd4242">*</span>户口详细地址：');
						$('.J_szq_detail label').text('请填写户口所在地详细地址');
						$('.J_szq_detail input').attr('valiflag', '384,full,户口所在地详细地址');
						$('#hjq').val(allObj.hjq);//户口区
						$('#hjszxxdz').val(allObj.hjszxxdz);//户口所在地详细地址

						$('.J_hkszd').hide();
						$('.J_hkszd #hjszd').attr({
							'paramete': 'hjqWs'
						});
						$('.J_hkszd #hjszd').removeAttr('v_require');
					} else {
						$('#isBjsy').val(isBjsy); //不是北京生源
						$.renderCode($('#syd'), 'gxbysjycy_d_xzqh_ws', '', '', function () {
							$('#syd').val(allObj.rxqhkszdxzqh);
						});//生源地

						$('.J_hkszd').show();
						$('.J_hkszd #hjszd').attr({
							'paramete': 'hjq',
							'v_require': ''
						});
						$.renderCode($('#hjszd'), 'gxbysjycy_d_xzqh_ws', '', '', function () {
							$('#hjszd').val(allObj.hjq);
						});//户口所在地

						$('#hjq').attr('paramete', 'czdxzqh');
						$('#hjszxxdz').attr('paramete', 'czdz');
						$('.J_szq .col-3').html('<span style="color:#fd4242">*</span>居住所在区：');
						$('.J_szq #hjq').attr('valiflag', ',full,居住所在区');
						$('.J_szq_detail .col-3').html('<span style="color:#fd4242">*</span>居住详细地址：');
						$('.J_szq_detail label').text('请填写居住所在地详细地址');
						$('.J_szq_detail input').attr('valiflag', '384,full,居住所在地详细地址');
						$('#hjq').val(allObj.czdxzqh);//户口区
						$('#hjszxxdz').val(allObj.czdz);//户口所在地详细地址
					}
					$('#xl').val(allObj.xl);//学历
					$('#byxx').val(allObj.byxx);//毕业学校
					$('#byrq').val(allObj.byrq);//毕业日期
					$('#sxzy').attr('xzqhid', allObj.sxzy);//所属专业
					$('#sxzy').val(allObj.sxzymc);//所属专业名称
					$('#sjhm').val(allObj.sjhm);//手机号码
					$('#jyyx').val(allObj.jyyx);//就业意向
					$('#yxyq').val(allObj.yxyq);//月薪要求
					$('#ryid').val(allObj.ryid);//人员id
					$('#bynd').val(allObj.bynd);//毕业年度
					if (allObj.flag == 0) {
						$('#dataForm input').attr('disabled', 'disabled');
						$('#dataForm select').attr('disabled', 'disabled');
					}
					if (allObj.sfybdhjjk == '1') {
						$('#isBjsy').attr('disabled', 'disabled');
					}
					loadValid();
					// 处理时间
					var max_time = allObj.dlsj;
					var min_time = (parseInt(max_time.substring(0, 4)) - 2) + '-01';
					dtPicker = new mui.DtPicker({
						type: 'month',
						beginDate: new Date(min_time),//设置开始日期
						endDate: new Date(max_time),//设置结束日期
					});
				}
			});
		}

		$(document).on('change', '#isBjsy', function () {
			var _val = $(this).val();
			isBjsyFn(_val);
		})
		/**
		 * @desc 是否是北京生源 做对应操作
		 * @param  Boolean flag 0:否 1：是
		 * */
		function isBjsyFn(flag) {
			if (flag == 1) {
				$.renderCode($('#syd'), 'gxbysjycy_d_xzqh', '', '');//生源地
				$('#hjq').val('');
				$('#hjszxxdz').val('');
				$('#hjq').attr('paramete', 'hjq');
				$('#hjszxxdz').attr('paramete', 'hjszxxdz');
				$('.J_szq .col-3').html('<span style="color:#fd4242">*</span>户口所在区：');
				$('.J_szq #hjq').attr('valiflag', ',full,户口所在区');
				$('.J_szq_detail .col-3').html('<span style="color:#fd4242">*</span>户口详细地址：');
				$('.J_szq_detail label').text('请填写户口所在地详细地址');
				$('.J_szq_detail input').attr('valiflag', '384,full,户口所在地详细地址');

				$('.J_hkszd').hide();
				$('.J_hkszd #hjszd').attr({
					'paramete': 'hjqWs'
				});
				$('.J_hkszd #hjszd').removeAttr('v_require');
			} else {
				$.renderCode($('#syd'), 'gxbysjycy_d_xzqh_ws', '', '');//生源地
				$('#hjq').val('');
				$('#hjszxxdz').val('');
				$('#hjq').attr('paramete', 'czdxzqh');
				$('#hjszxxdz').attr('paramete', 'czdz');
				$('.J_szq .col-3').html('<span style="color:#fd4242">*</span>居住所在区：');
				$('.J_szq #hjq').attr('valiflag', ',full,居住所在区');
				$('.J_szq_detail .col-3').html('<span style="color:#fd4242">*</span>居住详细地址：');
				$('.J_szq_detail label').text('请填写居住所在地详细地址');
				$('.J_szq_detail input').attr('valiflag', '384,full,居住所在地详细地址');
				$('.J_hkszd').show();
				$('.J_hkszd #hjszd').attr({
					'paramete': 'hjq',
					'v_require': ''
				});
				$.renderCode($('#hjszd'), 'gxbysjycy_d_xzqh_ws', '', '');//户口所在地
			}
		}
		function dmb() {
			$.renderCode($('#hjq'), 'gxbysjycy_d_xzqh');//户籍区
			$.renderCode($('#xl'), 'gxbysjycy_d_xldmb');//学历
			// 毕业年度
			$.fetch({
				url: '/smzdj/getBynd',
				type: 'get'
			}).done(function (res) {
				var _res = res.returnData;
				if (+_res.executeResult == 1) {
					var str = '<option value="">请选择</option>';
					$.each(_res.bynd, function (k, v) {
						str += '<option value="' + v + '">' + v + '</option>'
					});
					$('#bynd').html(str);
					// 回显
					search();
				}
			})
			getStudy();
		}

		//获取所学专业
		function getStudy() {
			$.fetch({
				url: '/smzdj/getCodeData',
				type: 'get',
				data: {
					dmbm: 'gxbysjycy_d_sxzydmb'
				}
			}).done(function (res) {
				var _res = res.returnData;
				if (+_res.executeResult == 1) {
					studyArr = _res.gxbysjycy_d_sxzydmb;
					var _data = [];
					deepLoop(studyArr, _data);
					getData(_data);
				} else {
					$.layerMsg(_res.message, '我知道了');
				}
			})
		}
		function deepLoop(arr, tar) {
			$.each(arr, function (k, v) {
				var obj = {};
				obj['value'] = v.id;
				obj['text'] = v.name;
				if (v.children) {
					obj['children'] = [];
					deepLoop(v.children, obj['children'])
				}
				tar.push(obj);
			})
		}
		function getData(data) {
			popPicker.setData(data);
		}


	});
</script>

</html>
